home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / a_utils / perl / perl5a1.lha / perl5alpha1 / do / gpwent < prev    next >
Encoding:
Text File  |  1992-08-15  |  2.0 KB  |  87 lines

  1. int
  2. do_gpwent(which,gimme,arglast)
  3. int which;
  4. int gimme;
  5. int *arglast;
  6. {
  7. #ifdef I_PWD
  8.     register ARRAY *ary = stack;
  9.     register int sp = arglast[0];
  10.     register STR *TARG;
  11.     struct passwd *getpwnam();
  12.     struct passwd *getpwuid();
  13.     struct passwd *getpwent();
  14.     struct passwd *pwent;
  15.  
  16.     if (which == O_GPWNAM) {
  17.     char *name = str_get(ary->ary_array[sp+1]);
  18.  
  19.     pwent = getpwnam(name);
  20.     }
  21.     else if (which == O_GPWUID) {
  22.     int uid = (int)str_gnum(ary->ary_array[sp+1]);
  23.  
  24.     pwent = getpwuid(uid);
  25.     }
  26.     else
  27.     pwent = getpwent();
  28.  
  29.     if (gimme != G_ARRAY) {
  30.     astore(ary, ++sp, TARG = str_mortal(&str_undef));
  31.     if (pwent) {
  32.         if (which == O_GPWNAM)
  33.         str_numset(TARG, (double)pwent->pw_uid);
  34.         else
  35.         str_set(TARG, pwent->pw_name);
  36.     }
  37.     return sp;
  38.     }
  39.  
  40.     if (pwent) {
  41.     (void)astore(ary, ++sp, TARG = str_mortal(&str_no));
  42.     str_set(TARG, pwent->pw_name);
  43.     (void)astore(ary, ++sp, TARG = str_mortal(&str_no));
  44.     str_set(TARG, pwent->pw_passwd);
  45.     (void)astore(ary, ++sp, TARG = str_mortal(&str_no));
  46.     str_numset(TARG, (double)pwent->pw_uid);
  47.     (void)astore(ary, ++sp, TARG = str_mortal(&str_no));
  48.     str_numset(TARG, (double)pwent->pw_gid);
  49.     (void)astore(ary, ++sp, TARG = str_mortal(&str_no));
  50. #ifdef PWCHANGE
  51.     str_numset(TARG, (double)pwent->pw_change);
  52. #else
  53. #ifdef PWQUOTA
  54.     str_numset(TARG, (double)pwent->pw_quota);
  55. #else
  56. #ifdef PWAGE
  57.     str_set(TARG, pwent->pw_age);
  58. #endif
  59. #endif
  60. #endif
  61.     (void)astore(ary, ++sp, TARG = str_mortal(&str_no));
  62. #ifdef PWCLASS
  63.     str_set(TARG,pwent->pw_class);
  64. #else
  65. #ifdef PWCOMMENT
  66.     str_set(TARG, pwent->pw_comment);
  67. #endif
  68. #endif
  69.     (void)astore(ary, ++sp, TARG = str_mortal(&str_no));
  70.     str_set(TARG, pwent->pw_gecos);
  71.     (void)astore(ary, ++sp, TARG = str_mortal(&str_no));
  72.     str_set(TARG, pwent->pw_dir);
  73.     (void)astore(ary, ++sp, TARG = str_mortal(&str_no));
  74.     str_set(TARG, pwent->pw_shell);
  75. #ifdef PWEXPIRE
  76.     (void)astore(ary, ++sp, TARG = str_mortal(&str_no));
  77.     str_numset(TARG, (double)pwent->pw_expire);
  78. #endif
  79.     }
  80.  
  81.     return sp;
  82. #else
  83.     fatal("password routines not implemented");
  84. #endif
  85. }
  86.  
  87.